<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.6/iconfont.css" rel="stylesheet"
	type="text/css" />
<link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet"
	type="text/css" />
<link href="css/common.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.css"
	rel="stylesheet" type="text/css" />
<link href="lib/region/css/city-picker.css" rel="stylesheet"
	type="text/css" />
<link href="lib/region/css/main.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>新增现场红包广告</title>
</head>
<body>
	<div class="pd-20">
		新增现场红包 <br />
		<form action="<%=path%>/backstage/bonus_han-add" method="post"
			class="form form-horizontal" id="form-u_bonus-add">
			<input type="hidden" id="id" name="id" value='${u_bonus.id}' />

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">企业主：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<span class="select-box"><select name="ent_id"
						class="select" datatype="*" nullmsg="请选择类型">
							<c:forEach items="${entrepreneurs}" var="entrepreneur">
								<option value="${entrepreneur.id}_${entrepreneur.user_id}">${entrepreneur.corp_fname}</option>
							</c:forEach>
					</select></span>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">投放类型：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<span class="select-box"><select name="resource_type"
						class="select" datatype="n" nullmsg="请选择类型"
						onchange="changeType(this.value)">
							<option value="0"
								<c:if test="${u_bonus.type==1}">selected="selected"</c:if>>图文</option>
							<option value="1"
								<c:if test="${u_bonus.type==2}">selected="selected"</c:if>>视频</option>
					</select></span>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">投放地区：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input id="city-picker3" class="form-control" readonly
						name="regioninfo" type="text"
						value="<c:if test="${u_bonus.advert.province!=''}">${u_bonus.advert.province}</c:if><c:if test="${u_bonus.advert.city!=''}">/${u_bonus.advert.city}</c:if><c:if test="${u_bonus.advert.area!=''}">/${u_bonus.advert.area}</c:if>"
						data-toggle="city-picker">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">投放范围：</label>
				<div class="formControls col-xs-8 col-sm-5"></div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">每次点击金额：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" readonly="readonly"
						class="input-text input-readyonly" value="1" placeholder="" id="">
				</div>
				<div class="formControls col-1">元/次</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">投放总金额：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text" value="${u_bonus.summy}"
						placeholder="" id="" name="summy" datatype="n" nullmsg="不能为空">
				</div>
				<div class="formControls col-1">元</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">实际点击次数：</label>
				<div class="formControls col-xs-8 col-sm-5"></div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">广告曝光次数：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text input-readyonly"
						value="${u_bonus.advert.show_times}" placeholder="" id=""
						name="show_times">
				</div>
				<div class="formControls col-1">万次</div>
			</div>

			<hr class="hr mt10" />

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">广告标题：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text" value="${u_bonus.title}"
						placeholder="" id="" name="title">
				</div>
			</div>


			<div id="imgresources">
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">缩略图：</label>
					<div class="formControls col-xs-8 col-sm-5">
						<div id="fileList_covers" class="uploader-list">
							<c:if test="${!empty u_bonus.advert.covers}">
								<div class="file-item thumbnail upload-state-done">
									<img style="width: 179px; height: 179px;"
										src="${u_bonus.advert.covers}" />
									<div class="info"></div>
								</div>
							</c:if>
						</div>
						<div id="filePicker_covers">选择图片</div>
						<input type="hidden" class="input-text"
							value="${u_bonus.advert.covers}" placeholder="" id="covers"
							name="covers">
					</div>
				</div>

				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">轮播图：</label>
					<div class="formControls col-xs-8 col-sm-5">
						<div id="fileList_resources" class="uploader-list">
							<c:if test="${!empty u_bonus.advert.advert_resources}">
								<c:forEach items="${u_bonus.advert.advert_resources}"
									var="resource">
									<div class="file-item thumbnail upload-state-done">
										<img style="width: 179px; height: 179px;"
											src="${resource.resource_url}" />
										<div class="info">
											<input type="hidden" value="${resource.resource_url}"
												name="resources" />
										</div>
									</div>
								</c:forEach>
							</c:if>
						</div>
						<div id="filePicker_resources">选择图片</div>
					</div>
				</div>

			</div>

			<div id="videourl" class="row cl" style="display: none;">
				<label class="form-label col-xs-4 col-sm-3">视频：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<div id="fileList_video" class="uploader-list">
						<c:if test="${!empty u_bonus.advert.videourl}">
							<div class="file-item thumbnail upload-state-done">
								<img style="width: 179px; height: 179px;"
									src="${u_bonus.advert.covers}" />
								<div class="info"></div>
							</div>
						</c:if>
					</div>
					<div id="filePicker_video">选择视频</div>
					<input type="hidden" class="input-text" value="" placeholder=""
						id="video" name="videoresource">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">祝福语：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text" value="${u_bonus.bless_word}"
						placeholder="至少10个字以上" id="" name="bless_word" datatype="*"
						nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">广告开始时间：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text Wdate"
						onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"
						value="${u_bonus.advert.start_time}" placeholder="" id=""
						name="start_time" datatype="*" nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">广告结束时间：</label>
				<div class="formControls col-xs-8 col-sm-5">
					<input type="text" class="input-text Wdate"
						value="${u_bonus.advert.end_time}"
						onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" placeholder="" id=""
						name="end_time" datatype="*" nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">最大红包金额：</label>
				<div class="formControls col-xs-4 col-sm-5">
					<input type="text" class="input-text" value="${u_bonus.max_money}"
						placeholder="" id="" name="max_money" datatype="n" nullmsg="不能为空">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">最小红包金额：</label>
				<div class="formControls col-xs-4 col-sm-5">
					<input type="text" class="input-text" value="${u_bonus.min_money}"
						placeholder="" id="" name="min_money" datatype="n" nullmsg="不能为空">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">有金额红包个数：</label>
				<div class="formControls col-xs-4 col-sm-5">
					<input type="text" class="input-text"
						value="${u_bonus.count_charge}" placeholder="" id=""
						name="count_charge">
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">无金额红包个数：</label>
				<div class="formControls col-xs-4 col-sm-5">
					<input type="text" class="input-text" value="${u_bonus.count_free}"
						placeholder="" id="" name="count_free">
				</div>
			</div>

			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<button onClick="u_bonus_save_submit();"
						class="btn btn-primary radius" type="submit">
						<i class="Hui-iconfont">&#xe632;</i> 保存并提交
					</button>
					<button onClick="layer_close();" class="btn btn-default radius"
						type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
				</div>
			</div>
		</form>
	</div>
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
	<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript" src="lib/icheck/jquery.icheck.min.js"></script>
	<script type="text/javascript"
		src="lib/Validform/5.3.2/Validform.min.js"></script>
	<script type="text/javascript"
		src="lib/webuploader/0.1.5/webuploader.min.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/ueditor.config.js"></script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
	<script type="text/javascript"
		src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" src="lib/region/js/city-picker.data.js"></script>
	<script type="text/javascript" src="lib/region/js/city-picker.js"></script>
	<script type="text/javascript" src="lib/region/js/main.js"></script>
	<script type="text/javascript">
	var baseurl;
	function changeType(value){
		if(value == "1"){
			$("#videourl").show();
			$("#imgresources").hide();
		}else{
			$("#videourl").hide();
			$("#imgresources").show();
		}
	}
	
	function u_bonus_save_submit(){
		$("#form-u_bonus-add").Validform({
			tiptype:2,
			ajaxPost:true,
			callback:function(form){
				var index = parent.layer.getFrameIndex(window.name);
			if (index){//关闭弹出层
				parent.$('.btn-refresh').click(); 
				parent.layer.close(index);
			}else{//单独的页面
				location.href = baseurl+"/backstage/u_bonus-list"; 
			}
		}
	});
	}

// 图片上传demo
$(function() {
	baseurl = '<%=path%>';
			/*企业Logo上传*/
			/*  var $list = $('#fileList_logo'), */
			var $list_covers = $('#fileList_covers'), $list_resources = $('#fileList_resources'), $list_video = $('#fileList_video'), ratio = window.devicePixelRatio || 1, thumbnailWidth = 100 * ratio, thumbnailHeight = 100 * ratio, uploader_resources, uploader_covers, uploader_video;

			/*广告封面上传*/
			uploader_covers = WebUploader.create({
				auto : true,
				swf : 'lib/webuploader/0.1.5/Uploader.swf',
				server : baseurl + '/backstage/common/uploadPic',
				pick : '#filePicker_covers',
				accept : {
					title : 'Images',
					extensions : 'gif,jpg,jpeg,bmp,png',
					mimeTypes : 'image/jpg,image/jpeg,image/png'
				},
				formData : {
					foldername : 'advert'
				}
			});

			uploader_covers
					.on(
							'fileQueued',
							function(file) {
								var $li = $('<div id="' + file.id + '" class="file-item thumbnail">'
										+ '<img>'
										+ '<div class="info">'
										+ file.name + '</div>' + '</div>'), $img = $li
										.find('img');

								$list_covers.html($li);
								uploader_covers.makeThumb(file, function(error,
										src) {
									if (error) {
										$img.replaceWith('<span>不能预览</span>');
										return;
									}

									$img.attr('src', src);
								}, thumbnailWidth, thumbnailHeight);
							});

			uploader_covers.on('uploadSuccess', function(file, response) {
				$('#' + file.id).addClass('upload-state-done');
				$("#covers").val(response.datas);
			});

			uploader_covers.on('uploadError', function(file) {
				var $li = $('#' + file.id), $error = $li.find('div.error');
				if (!$error.length) {
					$error = $('<div class="error"></div>').appendTo($li);
				}

				$error.text('上传失败');
			});

			uploader_covers.on('uploadComplete', function(file) {
				$('#' + file.id).find('.progress').remove();
			});

			/*轮播图上传*/
			uploader_resources = WebUploader.create({
				auto : true,
				swf : 'lib/webuploader/0.1.5/Uploader.swf',
				server : baseurl + '/backstage/common/uploadPic',
				pick : '#filePicker_resources',
				accept : {
					title : 'Images',
					extensions : 'gif,jpg,jpeg,bmp,png',
					mimeTypes : 'image/jpg,image/jpeg,image/png'
				},
				formData : {
					foldername : 'advert'
				}
			});

			uploader_resources
					.on(
							'fileQueued',
							function(file) {
								var $li = $('<div id="' + file.id + '" class="file-item thumbnail">'
										+ '<img>'
										+ '<div class="info"><input type="hidden" value="" name="resources" id="resource' + file.id + '"/></div>'
										+ '</div>'), $img = $li.find('img');

								$list_resources.append($li);
								uploader_resources.makeThumb(file, function(
										error, src) {
									if (error) {
										$img.replaceWith('<span>不能预览</span>');
										return;
									}

									$img.attr('src', src);
								}, thumbnailWidth, thumbnailHeight);
							});

			uploader_resources.on('uploadSuccess', function(file, response) {
				$('#' + file.id).addClass('upload-state-done');
				$("#resource" + file.id).val(response.datas);
			});

			uploader_resources.on('uploadError', function(file) {
				var $li = $('#' + file.id), $error = $li.find('div.error');
				if (!$error.length) {
					$error = $('<div class="error"></div>').appendTo($li);
				}
				$error.text('上传失败');
			});

			uploader_resources.on('uploadComplete', function(file) {
				$('#' + file.id).find('.progress').remove();
			});

			/*视频上传上传*/
			uploader_video = WebUploader.create({
				auto : true,
				swf : 'lib/webuploader/0.1.5/Uploader.swf',
				server : baseurl + '/backstage/common/uploadPic',
				pick : '#filePicker_video',
				accept : {
					title : 'videos',
					extensions : 'mp4,MP4',
					mimeTypes : '*'
				},
				formData : {
					foldername : ''
				}
			});

			uploader_video
					.on(
							'fileQueued',
							function(file) {
								var $li = $('<div id="' + file.id + '" class="file-item thumbnail">'
										+ '<img>'
										+ '<div class="info">'
										+ file.name + '</div></div>'), $img = $li
										.find('img');

								$list_video.html($li);
								uploader_video.makeThumb(file, function(error,
										src) {
									if (error) {
										$img.replaceWith('<span>不能预览</span>');
										return;
									}

									$img.attr('src', src);
								}, thumbnailWidth, thumbnailHeight);
							});

			uploader_video.on('uploadSuccess', function(file, response) {
				$('#' + file.id).addClass('upload-state-done');
				$("#video").val(response.datas);
			});

			uploader_video.on('uploadError', function(file) {
				var $li = $('#' + file.id), $error = $li.find('div.error');
				if (!$error.length) {
					$error = $('<div class="error"></div>').appendTo($li);
				}
				$error.text('上传失败');
			});

			uploader_video.on('uploadComplete', function(file) {
				$('#' + file.id).find('.progress').remove();
			});

		});
	</script>
</body>
</html>

